{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Error Bars showing Confidence Interval\n",
    "======================================\n",
    "This example shows how to show error bars using covidence intervals.\n",
    "The confidence intervals are computed internally in vega by\n",
    "a non-parametric [bootstrap of the mean](https://github.com/vega/vega-statistics/blob/master/src/bootstrapCI.js).\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import altair as alt\n",
    "alt.data_transformers.enable('json')\n",
    "from vega_datasets import data\n",
    "\n",
    "barley = data.barley()\n",
    "\n",
    "points = alt.Chart(barley).mark_point(filled=True).encode(\n",
    "    alt.X(\n",
    "        'mean(yield)',\n",
    "        scale=alt.Scale(zero=False),\n",
    "        axis=alt.Axis(title='Barley Yield')\n",
    "    ),\n",
    "    y='variety',\n",
    "    color=alt.value('black')\n",
    ")\n",
    "\n",
    "error_bars = alt.Chart(barley).mark_rule().encode(\n",
    "    x='ci0(yield)',\n",
    "    x2='ci1(yield)',\n",
    "    y='variety'\n",
    ")\n",
    "\n",
    "points + error_bars\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "env": {},
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {},
   "name": "python3"
  },
  "language": "python"
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
